﻿
<section class="content-header">
    <h1>
        文章管理
    </h1>
    <ol class="breadcrumb">
        <li><a href="@Url.Action("Index", "Home")"><i class="fa fa-home"></i> 首页</a></li>
        <li class="active">基础库</li>
    </ol>
</section>


<section class="content">
    <div class="row">
        <div class="col-lg-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <div class="dataTable-tools btn-group">
                        @Html.Bootstrap().LinkButton("添加", ToolBarIco.Create).Href(Url.Action("Create")).Attribute("data-toggle", "ajaxModal").Route(Url.Action("Create"))
                        @Html.Bootstrap().LinkButton("删除", ToolBarIco.Delete).Click("window.app.deleteItem('dataTable','" + @Url.Action("Delete") + "')").Route(Url.Action("Delete"))
                        @Html.Bootstrap().LinkButton("刷新", ToolBarIco.Refresh).Click("window.app.search();")
                    </div>
                    <div class="box-tools">

                        <div class="input-group input-group-sm SearchArea" style="width: 150px;">
                            <input type="text" name="Title" class="form-control pull-right" placeholder="标题">

                            <div class="input-group-btn">
                                <button type="button" class="btn btn-default" onclick="window.app.search();"><i class="fa fa-search"></i></button>
                            </div>
                        </div>
                    </div>
                    <div class="box-body no-padding">
                        <div class="table-responsive">
                            <table id="dataTable" class="table table-bordered table-striped table-hover dataTable text-center" width="100%"></table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<script type="text/javascript">
    $(document).ready(function () {

        $('#dataTable').dataTable({
            "serverSide": true,
            "ajax": {
                "url": "@Url.Action("GetPaged")",
                "type": "POST"
            },
            "columnDefs": [
                { "searchable": false, sortable: false, "orderable": false, "targets": [-1, 0, 1, 2] }, { "sClass": "editableCol", "aTargets": [1] }
            ],
            columns: [
                { title: '<label class="checkbox i-checks"><input type="checkbox" /><i></i></label>', data: function (row, type, set) { return '<label class="checkbox i-checks"><input type="checkbox" name="cellCheckbox" value="' + row.id + '" /><i></i></label>'; }, "bStorable": false, width: 30 },
                {
                    title: "标题", data: function (row) {
                        return '<a class="auto" data-toggle="ajaxModal" href="@Url.Action("Edit")/' + row.id + '">' + row.title + '</a>';
                    }, "sClass": "left"
                },
                { title: "事件日期", data: function (row) { return new Date(row.eventDay).format('yyyy-MM-dd') }, width: 100, "sClass": "center" }
                ,
                { title: "入库时间", data: function (row) { return new Date(row.checkInTime).format('yyyy-MM-dd HH:mm:ss') }, width: 140, "sClass": "center" }
                ,
                {
                    title: "是否原创", data: function (row) {
                        return row.isOriginal ? "<span class=\"label label-success\">原创</span>" : "<span class=\"label label-danger\">采集</span>";
                    }, width: 40, "sClass": "center"
                },
                {
                    title: "来自", data: function (row) {
                        return row.isOriginal ? "千树" : row.gatherName;
                    }, width: 120, "sClass": "center"
                },
                { "title": "源地址", data: function (row) { return row.url ? '<a href="' + row.url + '" target="_blank" title="' + row.url + '"><i class="fa fa-file-text"></i></a>' : ''; }, width: 40 }
            ]
        });
    });

</script>